define([
    "ngController"
],function (appAngular) {

    // 底部按钮组件（内部）
    appAngular.directive("bimApiBottom", function () {
        return {
            restrict: "EA",
            replace: true,
            template: `<div class="model-bottom-content">
						<div class="bottom-bg"></div>
							<div ng-repeat="item in btnsMsg" class="btn-every {{item.name==btnsSelect.name?btnEveryActive:null}}" 
							title="{{item.title}}" name="{{$index}}" ng-click="bottomBtnsClick(item, $index)">
							<img ng-src="{{baseUrl+item.img}}" />
						</div>
					</div>`,
            link: function ($scope, $elem, attrs) {
                // 当前选中（当前点击）
                $scope.btnsSelect = {
                    name: "",
                    check: ""
                };
                // 选中添加样式名称（点击按钮高亮）
                $scope.btnEveryActive = "btn-every-active";
                // 底部按钮数据
                $scope.btnsMsg = [
                    {
                        id: "",
                        name: "home",
                        title: "主视角",
                        isSelect: false,
                        img: "/Module/img/bottom-btns/btn-1-home.png",
                    }, {
                        id: "",
                        name: "property",
                        title: "属性",
                        isSelect: false,
                        img: "/Module/img/bottom-btns/btn-2-property.png",
                    }, {
                        id: "",
                        name: "structure",
                        title: "模型结构",
                        isSelect: false,
                        img: "/Module/img/bottom-btns/btn-3-structure.png",
                    }, {
                        id: "",
                        name: "eyesmark",
                        title: "视角书签",
                        isSelect: false,
                        img: "/Module/img/bottom-btns/btn-4-eyesmark.png",
                    }, {
                        id: "",
                        name: "search",
                        title: "搜索",
                        isSelect: false,
                        img: "/Module/img/bottom-btns/btn-5-search.png",
                    }, {
                        id: "",
                        name: "sign",
                        title: "标注",
                        isSelect: false,
                        img: "/Module/img/bottom-btns/btn-6-sign.png",
                    }, {
                        id: "",
                        name: "section",
                        title: "剖切",
                        isSelect: false,
                        img: "/Module/img/bottom-btns/btn-7-section.png",
                    }, {
                        id: "",
                        name: "measure",
                        title: "测量",
                        isSelect: false,
                        img: "/Module/img/bottom-btns/btn-8-measure.png",
                    }, {
                        id: "",
                        name: "location",
                        title: "定位",
                        isSelect: false,
                        img: "/Module/img/bottom-btns/btn-9-location.png",
                    }, {
                        id: "",
                        name: "3dbox",
                        title: "3D框选（请按住ctrl 拖动）",
                        isSelect: false,
                        img: "/Module/img/bottom-btns/btn-10-3dbox.png",
                    }, {
                        id: "",
                        name: "resolve",
                        title: "分解",
                        isSelect: false,
                        img: "/Module/img/bottom-btns/btn-11-resolve.png",
                    }, {
                        id: "",
                        name: "setting",
                        title: "设置",
                        isSelect: false,
                        img: "/Module/img/bottom-btns/btn-12-setting.png",
                    }/*, {
                        id: "",
                        name: "2d",
                        title: "二维",
                        isSelect: false,
                        img: "/Module/img/bottom-btns/btn-13-2d.png",
                    }*/
                ];
                // 触发按钮事件true
                $scope.btnsSeletCheck = function () {
                    $scope.btnsSelect.check = true;
                };
                // 底部按钮点击事件
                $scope.bottomBtnsClick = function (item, index) {
                    // 重置btnsSelect的值
                    $scope.btnsSelect.name = item.name;
                    $scope.btnsSelect.check = false;
                    // console.log(item, index);
                    // console.log($scope.btnsSelect);
                    // 模型加载
                    // Model.load  (url)
                    // 注：该方法传入后台模型接口url。
                    if (window.Model) {
                        // 初始化
                        // 标注
                        Model.singer(false);
                        Model.singerCancal();
                        // 剖切
                        Model.clip(false);
                    }
                    switch (index) {
                        case 0:
                            $scope.btnsSelect.check = true;
                            // 主视角
                            Model.reset();
                            break;
                        case 1:
                            $scope.btnsSelect.check = true;
                            // 属性
                            break;
                        case 2:
                            $scope.btnsSelect.check = true;
                            // 模型结构
                            break;
                        case 3:
                            // 内容初始化
                            $scope.modelEyesmark.name = "";
                            $scope.modelEyesmark.comment = "";
                            $scope.modelEyesmark.colorIndex = "#f65f74";
                            // 视角书签
                            $scope.btnsSelect.check = true;
                            //保存视角书签
                            // Model.saveMark(name,callback)
                            // 注：参数有两个，name和callback
                            // 1.name设置标签的名称
                            // 2.callback是标签的回调函数，用于设置标签的其他内容，callback接受一个参数，参数对象的url为截屏缩略图。

                            //提取视角书签
                            // Model.parseMark(markJson)
                            // 注:参数为一个json,这里为存入数据库的视角数据
                            break;
                        case 4:
                            $scope.btnsSelect.check = true;
                            // 搜索
                            break;
                        case 5:
                            // 内容初始化
                            $scope.modelSign.name = "";
                            $scope.modelSign.comment = "";
                            $scope.modelSign.colorIndex = "#f65f74";
                            // 标注-开始划线-操作在组件中
                            Model.singer(true);
                            break;
                        case 6:
                            $scope.btnsSelect.check = true;
                            // 剖切
                            Model.clip(true);
                            //层间滑动
                            // Model.slide(value)
                            // 注：该方法传入一个value对象，value中包含x,y,z三个属性。
                            // 1.x控制X方向平移
                            // 2.y控制Y方向平移
                            // 3.z控制Z方向平移

                            // 层间滑动重置
                            // Model.resetSlide()
                            // 注：该方法没有参数。
                            break;
                        case 7:
                            $scope.btnsSelect.check = true;
                            // 测量
                            // Model.measure(true);
                            break;
                        case 8:
                            $scope.btnsSelect.check = true;
                            // 定位
                            /*if (API.object && API.object.name) {
                                API.location([API.object.name]);
                            }*/
                            // API.changeCamera();
                            break;
                        case 9:
                            $scope.btnsSelect.check = true;
                            // 3D框选（请按住ctrl 拖动）
                            // API.frame();
                            break;
                        case 10:
                            $scope.btnsSelect.check = true;
                            // 分解
                            break;
                        case 11:
                            $scope.btnsSelect.check = true;
                            // 设置
                            break;
                        case 12:
                            $scope.btnsSelect.check = true;
                            // 二维
                            break;
                        case 13:
                            $scope.btnsSelect.check = true;
                            // 暂时是空的
                            break;
                        default:
                            // 暂时只有13个，so：case：13是空的
                            break;
                    }
                };
            }
        };
    });

    return appAngular;
});